<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>

<style>
	#search_table {text-align:center;border:1px solid #ddd; border-width:0 0 1px 1px;}
	
	#search_table th {background:#CCEEFF;}
	#search_table th,#search_table td {height:22px; border:1px solid #ddd; border-width:1px 1px 0 0;}
</style>

<script type="text/javascript">
<!--
	function disableUser(userId){
		window.location.href = "./UserMgr_updateUserStatus.do?updateStatus=0&editUserId="+userId;
	}
	
	function enableUser(userId){
		window.location.href = "./UserMgr_updateUserStatus.do?updateStatus=1&editUserId="+userId;
	}
	
	function editUser(userId){
		window.location.href = "./UserMgr_editUser.do?editUserId="+userId;
	}
	
	function createUser(){
		window.location.href = "./UserMgr_userCreate.do";
	}
//-->
</script>
<div style="background-color:#F5F5F5;margin-top:1cm;" >
	<div align="left">
			<s:actionmessage cssStyle="color:#0000FF;"/>
			<s:actionerror cssStyle="color:#F00;"/>
	</div>
	<table width="80%"  align="center">
		<tr>
			<td align="right">
				<input type="button" class="btn" value="<s:text name="action.create"/>" onclick="createUser()">
			</td>
		</tr>
	</table>
	<table width="100%" id="search_table">
		<thead>
			<tr class="ui-widget-header">
				<th style="width: 10em;"><s:text name="user.userRole"/></th>
				<th style="width: 10em;"><s:text name="user.username"/></th>
				<th style="width: 10em;"><s:text name="user.userCode"/></th>
				<th style="width: 30em;"><s:text name="user.userCompName"/></th>
				<th style="width: 10em;" colspan="2"><s:text name="action.action"/></th>
			</tr>
		</thead>
		<tbody>
			<s:include value="./component/result_empty.jsp"></s:include>
			<c:forEach var="each" items="${pm.datas}">
				<tr>
					<td>${each.roleName}</td>
					<td>${each.username}</td>
					<td>${each.userCode}</td>
					<td>${each.userCompName}</td>
					<c:if test="${each.status == 1}">
					     <c:if test="${each.userRole != 2}">
							<td><input type="button" class="btn" value="<s:text name="entity.status.Disabled"/>" onclick="disableUser('${each.id}')"></td>
					     </c:if>
						<td><input type="button"  class="btn" value="<s:text name="action.edit"/>" onclick="editUser('${each.id}')">
					</c:if>
					<c:if test="${each.status == 0}">
						<td><input type="button" class="btn" value="<s:text name="entity.status.Enabled"/>" onclick="enableUser('${each.id}')"></td>
						<td></td>
					</c:if>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</div>